﻿namespace DomainCommons.Models
{
    /// <summary>
    /// 使用泛型仓储得类型都应该用上
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class BaseEntity<T> : IEntity<T>, IHasCreationTime, IHasDeletionTime, ISoftDelete,IHasUpdateTime where T : new()
    {
        public T Id { get; set; } = new T();
        public string? Name { get; set; }
        public string? Description { get; set; }

        public bool IsDeleted { get; set; }

        public DateTime? DeletionTime { get; set; }

        public DateTime CreationTime { get; set; }
        public DateTime? UpdateTime { get; set; }

        public void SoftDeleted()
        {
            this.IsDeleted = true;
            this.DeletionTime = DateTime.Now;
        }
        public BaseEntity()
        {
            this.CreationTime = DateTime.Now;
        }

    }
}
